<template>
	<view style="padding-bottom:100px;">
	    <view class="swbanner wdd1">
	        <swiper autoplay="true">
	            <block v-for="item in banner_list" >
	                <swiper-item>
	                    <view class="swiper-item"   >
	                        <image :src="item.pic" mode="widthFix" class="swbanner"></image>
	                    </view>
	                </swiper-item>
	            </block>
	        </swiper>
	    </view>
	    <view class="myintegral">
	        <view class="integraldv"  @click="user_integral_log">
	            <view class="span flexd">
	              <image class="jifendd" src="https://ayh.wissun.net/static/ayh/jifen.png" mode="widthFix"/>
	              <view class="lrrgin">积分余额：</view>
	            </view>
	            <view class="span" >{{jxs_integral}}积分</view>
	        </view>
	        <view class="ruledv" style="display: flex;">
	           <view class="dhjlc" @click="duihuan">兑换记录</view>
	        </view>
	    </view>
	
	    <view class="contents">
	        <view class="item" v-for="item in goodslist"  @click="lijidui(item)" >
	            <image :src="item.goods_pic"   />
	            <view class="integraldv1">{{item.goods_name}}</view>
	            <view class="ku">库存：{{item.stock}}件</view>
	            <view >
	                <view class="privice"  style="color: #1B764A;">
	                    <view class="jinbiclass" >{{item.integral}}积分</view>
	                    <block v-if="item.amount">
	                        +¥{{item.amount}}元
	                    </block>
	                </view>
	            </view>
	        </view>
	    </view>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				banner_list:[
					{pic:"https://ayh.wissun.net/static/ayh/nnn23.jpg"}
				],
				jxs_integral:0,
				goodslist:[]
			}
		},
		onLoad() {
			
		},
		onShow() {
			//this.get_user_data();
			this.get_data();
		},
		methods: {
			get_data(){
				var postdata={};
				var that=this
				postdata.user_code=uni.getStorageSync("fahuo_username").user_code
				this.request('/api/integral_shop_front/get_jxs_goods_list', postdata,"post").then(data => {
					that.goodslist=data.info.integral_goods
					that.jxs_integral=data.info.jxs_integral
				})
			},
			user_integral_log(){
				uni.navigateTo({
					url:"/pages/main/duojifahuo/shop/user_integral_log"
				})
			},
			get_user_data(){
				var that=this;
				var postdata={}
				postdata.openid=uni.getStorageSync("openid")
				this.request('/api/index/get_user_info', postdata,"post").then(data => {
					that.wxuserinfo=data.info
				})
			},
			duihuan(item){
				if(this.jxs_integral < item.integral){
					uni.showToast({ title:"积分不足",icon:"none"})
					return
				}
				uni.navigateTo({
					url:"/pages/main/duojifahuo/shop/order"
				})
			},
			lijidui(item){
				var user_id=uni.getStorageSync("fahuo_username").id
				var goods_id=item.id
				if(this.jxs_integral  < item.integral){
					uni.showToast({ title:"积分不足",icon:"none"})
					return
				}
				uni.navigateTo({
					url:"/pages/main/duojifahuo/shop/comfirm_order?user_id="+user_id+"&goods_id="+goods_id
				})
			}
		}
	}
</script>

<style>
.myintegral {
    height: 40px;
    line-height: 40px;
    width: calc(100% - 20px);
    margin: 0 auto;
    display: flex;
    /* background: url(https://second.wissun.net/Public/newhome/img/icon05.png); */
    background-color: #fff;
    background-size: 100% 100%;
    justify-content: space-between;
}
page{
  background-color: #eee;
}
.he100{
  height: 100px;
}
.integraldv {
    display: flex;
    line-height: 40px;
    float: left;
    font-size: 14px;
    padding-left: 10px;
}
.integraldv .span:nth-child(1) {
    color: #000;
    font-size: 14px;
}
.integraldv .span:nth-child(2) {
    color: #000;
    font-size: 14px;
}
.ruledv image {
    height: 27px;
    width: 81px;
    margin-right: 10px;
}
.ruledv {
    font-size: 14px;
    color: rgba(121, 208, 255, 1);
}
.nav_dh {
    background: unset;
    height: 40px;
    line-height: 40px;
    
    border-bottom: 1px solid #00A1A9;
    box-sizing: border-box;
    width: calc(100% - 20px);
    margin: 0 auto;
    margin-top: 10px;
    overflow-y: auto;
}
.huandong .active {
    background: unset;
    /* border-bottom: 4px solid #00A1A9; */
    border-bottom: 4px solid #185ab0;
    
}
.nav_dh .ul .li {
    float: left;
    line-height: 35px;
    font-size: 14px;
    text-align: center;
    width: 24%;
    height: 35px;
}
.nav_dh .ul .li .a {
    color: #9D9D9D;
}
.flexd{
  display: flex;
}
.jifendd{
  width: 20px;
  position: relative;
  top: 10px;
}
.item:nth-child(1){
  margin-top: 10px;
}
.item:nth-child(2){
  margin-top: 10px;
}
.lrrgin{
  padding-left: 3px;
}
.item {
    width: calc(50% - 10px);
    display: flex;
    font-size: 12px;
    flex-direction: column;
    margin: 5px;
    float: left;
    text-align: center;
    background-color: #fff;
    border-radius: 5px;
}
.item image {
    width: 85%;
    margin: 10px auto;
    border-radius: 8px;
    height: 120px;
}
.duih {
    border: 1px solid #a09c9c;
    width: 82px !important;
    border-radius: 20px;
    margin: 10px auto !important;
    height: 23px;
    line-height: 23px;
}
.integraldv1 {
    height: 20px;
    line-height: 20px;
    font-size: 14px;
    text-align: left;
    padding-left: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #292929;
    padding-top: 10px;
}
.contents{
  width: calc(100% - 20px);
  margin: 0 auto;
}
.privice{
  text-align: left;
  display: flex;
  padding: 15px 0px;
  padding-left: 10px;
}
.jinbiclass{
  color: #1B764A;
  font-weight: bold;
  font-size: 14px;
}
.ku{
    height: 20px;
    line-height: 20px;
    font-size: 12px;
    color: #999;
    text-align: left;
    padding-left: 10px;
}
.swbanner{
    width: 100%;
    height: 345rpx;
    margin: 0 auto;
    border-radius: 4px;
}
.wdd1{
  width:calc(100% - 20px);
  margin: 10px auto;

}
swiper{height: 345rpx !important;}
.dhjlc{
    width: 48px;
    line-height: 36px;
    text-align: center;
    border-radius: 20px;
    border:2px solid #fff;
    color: #000;
    font-weight: bold;
    margin-right: 5px;
    font-size: 12px;
}
</style>
